package com.lemon.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import com.lemon.common.log.annotation.Log;
import com.lemon.common.log.enums.BusinessType;
import com.lemon.common.security.annotation.RequiresPermissions;
import com.lemon.system.domain.BiFeedback;
import com.lemon.system.service.IBiFeedbackService;
import com.lemon.common.core.web.controller.BaseController;
import com.lemon.common.core.web.domain.AjaxResult;
import com.lemon.common.core.utils.poi.ExcelUtil;
import com.lemon.common.core.web.page.TableDataInfo;

/**
 * 包名称：com.lemon.system.controller
 * 类名称：BiFeedbackController
 * 类描述：用户反馈Controller
 * 创建人：@author lemon
 * 创建时间：2023-09-14
 */
@Api("用户反馈")
@RestController
@RequestMapping("/feedback")
public class BiFeedbackController extends BaseController {

    @Autowired
    private IBiFeedbackService biFeedbackService;

    /**
     * 查询用户反馈列表
     * @Title: list
     * @Description: 查询用户反馈列表
     * @param biFeedback 用户反馈
     * @return: TableDataInfo
     * @throws:
     * @author: lemon
     * @Date: 2023-09-14
     */
    @RequiresPermissions("system:feedback:list")
    @GetMapping("/list")
    public TableDataInfo list(BiFeedback biFeedback) {
        startPage();
        List<BiFeedback> list = biFeedbackService.selectBiFeedbackList(biFeedback);
        return getDataTable(list);
    }

    /**
     * 导出用户反馈列表
     * @Title: export
     * @Description: 导出用户反馈列表
     * @param response 客户端响应对象
     * @param biFeedback 用户反馈
     * @return:
     * @throws:
     * @author: lemon
     * @Date: 2023-09-14
     */
    @RequiresPermissions("system:feedback:export")
    @Log(title = "用户反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BiFeedback biFeedback) {
        List<BiFeedback> list = biFeedbackService.selectBiFeedbackList(biFeedback);
        ExcelUtil<BiFeedback> util = new ExcelUtil<BiFeedback>(BiFeedback.class);
        util.exportExcel(response, list, "用户反馈数据");
    }

    /**
     * 获取用户反馈详细信息
     * @Title: getInfo
     * @Description: 获取用户反馈详细信息
     * @param id 用户反馈主键
     * @return: AjaxResult
     * @throws:
     * @author: lemon
     * @Date: 2023-09-14
     */
    @RequiresPermissions("system:feedback:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(biFeedbackService.selectByPrimaryKey(id));
    }

    /**
     * 新增用户反馈
     * @Title: add
     * @Description: 新增用户反馈
     * @param biFeedback 用户反馈
     * @return: AjaxResult
     * @throws:
     * @author: lemon
     * @Date: 2023-09-14
     */
    @RequiresPermissions("system:feedback:add")
    @Log(title = "用户反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BiFeedback biFeedback) {
        return toAjax(biFeedbackService.insert(biFeedback));
    }

    /**
     * 修改用户反馈
     * @Title: edit
     * @Description: 修改用户反馈
     * @param biFeedback 用户反馈
     * @return: AjaxResult
     * @throws:
     * @author: lemon
     * @Date: 2023-09-14
     */
    @RequiresPermissions("system:feedback:edit")
    @Log(title = "用户反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BiFeedback biFeedback) {
        return toAjax(biFeedbackService.update(biFeedback));
    }

    /**
     * 删除用户反馈
     * @Title: remove
     * @Description: 删除用户反馈
     * @param ids 需要删除的用户反馈主键集合
     * @return: AjaxResult
     * @throws:
     * @author: lemon
     * @Date: 2023-09-14
     */
    @RequiresPermissions("system:feedback:remove")
    @Log(title = "用户反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(biFeedbackService.deleteByBatch(ids));
    }
}
